<template>
  <div>
    <!-- <MyCounter ref="counter"></MyCounter>
    <button @click="showRef">按钮</button> -->
    <input type="text" ref="ipt" v-if="showInput">
    <button ref="btn" v-else @click="showRef">按钮</button>
  </div>
</template>

<script>
// import MyCounter from './components/counter.vue'
export default {
  name: 'MyApp',
  components: {
    // MyCounter
  },
  data() {
    return {
      showInput: false
    }
  },
  methods: {
    showRef() {
      this.showInput = true
      this.$nextTick(() => {
        console.log(this.$refs.ipt)
        this.$refs.ipt.focus()
      })
    }
  }
}
</script>

<style>

</style>